home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / borland / prbgi097.zip / C.ZIP / HARDERRH.C < prev    next >
C/C++ Source or Header  |  1992-12-15  |  2KB  |  98 lines

  1. #include "PrtGraph.h"
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <conio.h>
  6. #include <dos.h>
  7. #include <Ctype.h>
  8.  
  9. #include "OUTMSG.H"
  10.  
  11.  
  12. #ifndef  _HARDERR_IGNORE
  13.    #define _HARDERR_IGNORE  0
  14.    #define _HARDERR_RETRY   1
  15.    #define _HARDERR_ABORT   2
  16.    #define _HARDERR_FAIL    3
  17. #endif
  18.  
  19.  UserResponce(const char *msg1, const char *msg2)
  20.  {
  21.     int retval;
  22.     int c;
  23.     //void far *p=NULL;
  24.     if ( BGIactive(Scrn_BGIgroup) )
  25.        Outmsg(msg1,msg2,NULL);
  26.     else
  27.        cputs(msg1); cputs("\r\n"); cputs(msg2);
  28.  
  29.     do
  30.     {
  31.         c = toupper(getch());
  32.        if ( c!=0 )
  33.           switch (c)
  34.           {
  35.              case 'A':  retval = _HARDERR_ABORT; break;
  36.              case 'R':  retval = _HARDERR_RETRY; break;
  37.              case 'I':  retval = _HARDERR_IGNORE; break;
  38.              default: c=0;
  39.           }
  40.        else getch();
  41.     } while ( c==0 );
  42.     CloseOutmsg(NULL);
  43.     return(retval);
  44.  }
  45.  
  46.  
  47.  #pragma warn -par
  48.  int harderr_handler(int errval,int ax,int bp,int si)
  49.  {
  50.     char msg1[20];
  51.     char msg2[]="A)bort, R)etry, F)ail";
  52.     //unsigned di;
  53.     int drive;
  54.     //int errorno;
  55.     int rc;
  56.  
  57.     //di= _DI;
  58.  
  59.     if (ax < 0)
  60.     {
  61.        /* not a disk */
  62.        _fstrcpy(msg1,"Error on ");
  63.        _fstrncat(msg1,(const char far*)MK_FP(bp,si+0xa),8);
  64.     }
  65.     else
  66.     {
  67.        /* otherwise it was a disk error */
  68.           drive = ax & 0x00FF;
  69.           //errorno = di & 0x00FF;
  70.           _fstrcpy(msg1,"Error on drive x:");
  71.            msg1[15] = 'A' + drive;
  72.     }
  73.     rc = UserResponce(msg1,msg2);
  74.     if (rc==_HARDERR_IGNORE) hardretn(rc);
  75.     if (rc==_HARDERR_ABORT)
  76.     {
  77.        if ( BGIactive(0) ) closegraph();
  78.     }
  79.     hardresume(rc);
  80.     return _HARDERR_ABORT;
  81.  }
  82.  #pragma warn +par
  83.  
  84.  
  85. //#pragma saveregs
  86. #pragma option -r-
  87. #pragma option -N-
  88. #ifdef __cplusplus
  89.    void interrupt CtrlBreak_handler(...)
  90. #else
  91.    void interrupt CtrlBreak_handler(void)
  92. #endif
  93. {
  94.    PRT_HaltPrinting=1;
  95.    return;
  96. }
  97.  
  98.